﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using V5_Common;
using V5_Model;
using V5_BLL;
using System.Data;

namespace V5_EShop.Admin
{
    public partial class Admin_Menu_Product_Class : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TreeViewMenu_TreeNodePopulate(object sender, TreeNodeEventArgs e)
        {
            if (IsCallback)
            {
                if (e.Node.ChildNodes.Count == 0)
                {
                    Bind_ProductClassList(e.Node);
                }
            }
        }

        private void Bind_ProductClassList(TreeNode node)
        {
            string ClassID = node.Value;
            DataTable dt = new BLLProductClass().GetList(" ParentID=" + Utils.FilterInjection(ClassID)).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    TreeNode subNode = new TreeNode(row["ClassName"].ToString());
                    //subNode.SelectAction = TreeNodeSelectAction.SelectExpand;
                    subNode.PopulateOnDemand = true;
                    subNode.NavigateUrl = "Admin_Product.aspx?ClassID=" + row["ClassID"].ToString();
                    subNode.Target = "main";
                    subNode.Value = row["ClassID"].ToString();
                    node.ChildNodes.Add(subNode);
                }
            }
        }
    }
}
